//
//  AccountTool.swift
//  开心微博
//
//  Created by 郑开心 on 15/12/10.
//  Copyright © 2015年 郑开心. All rights reserved.
//

import UIKit

private let accountFileName = "account"

class AccountTool: NSObject {
    
    class func saveAccount(account: Account){
        Account.save(obj: account, name: accountFileName, duration: 0)

    }
    
    class func readAccount() -> Account? {
        let account = Account.read(name: accountFileName)
        
        
        if let account1 = account.1 as? Account {
            if  NSDate().compare(account1.expires_date) == NSComparisonResult.OrderedDescending {
                return nil
            }else{
                return account1
            }
        }else{
            return nil
        }
        
    }
    
}
